﻿var
    //x = Math.floor(Math.random() * 600),
    time = 10800,
    c = [],
    ctx,
    width = 4000,
    height = window.innerHeight-325,
    ob = [],
    fps = 1000 / 60,
    delta = 300 / fps;

var Lab = function () {
    for (j = 0; j < viewData.length; j++) {
        if (viewData[j].NoteNumber <= 88)
            ob.push(new block(viewData[j].NoteNumber - 27, 0 - viewData[j].Time, viewData[j].Length));
    }
};

var initialized = function () {
    gLoop = setTimeout(initialized, fps);
    autorun();
    //clearTimeout(gLoop);
};

var autorun = function () {
    c = document.getElementById('cvMain');
    c.width = width;
    c.height = height;
    ctx = c.getContext('2d');

    for (i = 0; i < ob.length; i++) {

        if ((ob[i].Y) < height) {
            //ob[i].clearScreen();

            ob[i].CheckId();
            ob[i].Draw();
            ob[i].Y += delta;

            //TuCuong
            //PressNote(ob[i].id);
        }
        else {
            ob.splice(i, 1);
        }
    }
}